<template>
  <!-- 项目进度照片收集 -->
  <base-breadcrumb :title="$route.meta.title">
    <!-- 搜索 -->
    <searchData :searchData="searchArr" @search="search"></searchData>
    <!-- 表格 -->
    <a-card :bordered="false">
      <!-- <title-name :title="$route.meta.title"></title-name> -->
      
      <!-- 表格 -->
      <list-table
          ref="table"
          row-key="id"
          :columns="columns"
          :request="loadData"
          :alert="true"
          show-size-changer
          show-quick-jumper
      >
      <a-button slot="prefix" v-btnPermission="'oa_002_add_01'" class="mb12" icon="plus" type="primary" @click="handleManage(2)">新增</a-button>
        <template slot="action" slot-scope="text, record">
          <MoreButton>
          <a @click="handleManage(0, record)">查看</a>
          <!-- 若岗位为公司或者分公司办公室，以及项目办公室则此条数据可操作 -->
          <template
            v-if="post === 'COADAZG' || post === 'BCADAGL' || (record.isOperation === '2' && post === 'PDTMQMZLY')"
          >
            <!-- 编辑 -->
            <a v-btnPermission="'oa_002_edi_02'" @click="handleManage(1, record)">编辑</a>
            <!-- 删除 -->
            <a v-btnPermission="'oa_002_del_03'" class="del_btn" @click="handleRemove(record.id)">删除</a>
          </template>
          </MoreButton>
        </template>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>

<script>
// import { STable } from '@/components' // 表格
import { projectImagesCollect } from '@/api/office/office/enterpriseHonorAndImgCollect' // api
import BasePage from '@/views/basePage' // 基础配置
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目名称
import OrgTreeSelect from '@/components/OrgTreeSelect'

const columns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    },
  },
  {
    title: '分公司',
    ellipsis: true,
    dataIndex: 'branchComName',
  },
  {
    title: '项目名称',
    ellipsis: true,
    dataIndex: 'projectName',
  },
  {
    title: '施工阶段',
    ellipsis: true,
    dataIndex: 'constructionStage',
  },
  {
    title: '拍摄时间',
    ellipsis: true,
    dataIndex: 'photographTime',
  },
  {
    title: '拍摄地点',
    ellipsis: true,
    dataIndex: 'photographPlace',
  },
  {
    title: '创建人',
    dataIndex: 'founder',
    ellipsis: true,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    ellipsis: true,
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: '180px',
    align: 'center',
    scopedSlots: { customRender: 'action' },
  },
]
export default {
  name:'a'+Date.now(),
  extends: new BasePage(),
  components: {
    // STable,
  },
  data() {
    this.columns = columns
    return {
      queryParam: {}, // 查询参数
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, { query: this.queryParam })
        return projectImagesCollect.getList(requestParameters).then((res) => {
          return res
        })
      }, // 加载数据方法 必须为 Promise 对象
      removeApi: projectImagesCollect, // api
      editModel: 0,
      post: '', // 岗位code
    }
  },
  computed: {
    searchArr() {
      return [
        // 搜索框
        {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
        // {
        //   name: '分公司',
        //   type: SelectSubCompany,
        //   disabled: this.$currentPost().code != 'CO',
        //   autoSelected:this.$currentPost().code != 'CO',
        //   valueKey: 'branchComId',
        // },
        // {
        //   name: '项目名称',
        //   type: SelectProject,
        //   valueKey: 'projectId',
        //   keyValue: 'branchComId',
        // },
        {
          name: '施工阶段',
          type: 'input',
          value: 'constructionStage',
        },
      ]
    },
  },
  mounted() {
    // 初始化岗位信息
    this.post = this.$currentPost().postCode
  },
  methods: {
    // 搜索
    search(value) {
      value && (this.queryParam = value)
      this.$refs.table.refresh(true)
    },
    // 操作栏
    handleManage(type, record) {
      this.editModel = type
      let query = {
        editModel: type,
      }
      if (record && record.id) {
        query.id = record.id
      }
      this.$router.push({
        name: '/office/photoCollection/photoCollectionEdit',
        query,
      })
    },
  },
}
</script>
